/*
 * Package il.ac.biu.cs.grossmm.api.presence
 * File Entity.java
 * 
 * This is a part of presence service framework API. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package il.ac.biu.cs.grossmm.api.presence;

import il.ac.biu.cs.grossmm.api.OperationFailedException;

import java.util.Set;

/**
 * Represents an entity such as presentity or a watcher. Entity is essentially a
 * user which either interacts directly with the system or is inderectly refered
 * in such interactions.
 * <p>
 * Each entity belongs to one or more entity types and may be associated with
 * one or more identifiers.
 * <p>
 * There are two kinds of entities:
 * <ul>
 * <li> Permanent entities - entities permanently registered on the system
 * <li> Temporary entities - entities valid for a short range of time,
 * information about these entities is not persistent
 * </ul>
 * 
 */
public interface Entity {
	/**
	 * When this method returns false, any information returned by the rest of
	 * the methods should not be considered valid. Normally invalid entities are
	 * entities deregistered from the system.
	 * 
	 * @return true iff this object contains a valid entity state
	 */
	boolean isValid();

	/**
	 * Returns true iff the entity is a permanently registered on the system,
	 * otherwise the entity is valid for a short range of time, information
	 * about these entities is not persistent.
	 * 
	 * @return true iff the entity is a permanently registered on the system
	 */
	boolean isPermanent();

	/**
	 * Checks whether this entity belongs to a specified entity type.
	 * 
	 * @param entityType
	 * @return true iff this entity belongs to a specified entity type
	 */
	boolean is(EntityType entityType);

	/**
	 * Returns all entity identifiers.
	 * 
	 * @return all entity identifiers
	 */
	Set<String> getIdentifiers();

	/**
	 * Gets a property of the entity.
	 * 
	 * @param entity
	 *            the entity of interest
	 * @param property
	 *            the property of interest
	 * @return value of the property or null if there is no such property for
	 *         this entity
	 */
	<T> T getProperty(String property) throws OperationFailedException;
}
